//
//  CCImageCell.m
//  Activity
//
//  Created by its on 15/5/12.
//  Copyright (c) 2015年 coco. All rights reserved.
//

#import "CCImageCell.h"
#import <Masonry/Masonry.h>
#import <ReactiveCocoa/ReactiveCocoa.h>

@interface CCImageCell();
@end
@implementation CCImageCell

- (id) initWithImage:(UIImage *) image closeImage:(UIImage *)closeImage {
  if (self = [super init]) {
    _imageView = [[UIImageView alloc] init];
    _imageView.image = image;
    _closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_closeButton setImage:closeImage forState:UIControlStateNormal];
    [self addSubview:_imageView];
    [self addSubview:_closeButton];
  }
  return self;
}
- (void) setCloseBlock:(void(^)(void))block {
  _closeButton.rac_command = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
    block();
    return [RACSignal empty];
  }];
}
- (void) layoutSubviews {
  [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.edges.equalTo(self);
  }];
  [self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
    make.right.equalTo(self);
    make.top.equalTo(self);
    make.size.mas_equalTo(CGSizeMake(24, 24));
  }];
  
}

@end
